<?php

use App\Http\Controllers\Api\AuthController;
use App\Http\Controllers\Api\GroupController;
use App\Http\Controllers\Api\UserController;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider and all of them will
| be assigned to the "api" middleware group. Make something great!
|
*/

/**
 * 无需权限校验路由
 */
Route::group(['prefix' => 'v1'], function () {
    // 用户注册
    Route::post('/user/register', [UserController::class, 'register']);
    // 用户登录
    Route::post('/user/login', [UserController::class, 'login']);
});

/**
 * 需要权限校验的路由
 */
Route::group(['middleware' => 'auth.check', 'prefix' => 'v1'], function () {
    // 刷新token
    Route::get('/user/refresh_token', [UserController::class, 'refresh_token']);
    // 注销登录
    Route::get('/user/logout', [UserController::class, 'logout']);
    // 获取当前用户信息
    Route::get('/user/get_self_info', [UserController::class, 'get_self_info']);
});

/**
 * 管理后台专用路由
 */
Route::group(['middleware' => 'auth.check', 'prefix' => 'v1/manager'], function () {
    // 创建/修改用户组
    Route::post('/group/create', [GroupController::class, 'create']);
    // 获取用户组列表
    Route::get('/group/list/{flag}', [GroupController::class, 'query']);
    // 启用/禁用用户组
    Route::post('/group/status', [GroupController::class, 'status']);

    // 创建/修改权限菜单
    Route::post('/auth/create', [AuthController::class, 'create']);
    // 获取权限菜单列表
    Route::get('/auth/list/{flag}', [AuthController::class, 'query']);
    // 删除权限菜单
    Route::post('/auth/delete', [AuthController::class, 'delete']);

    // 创建用户
    Route::post('/user/create', [UserController::class, 'create']);
    // 获取用户列表
    Route::get('/user/list/{flag}/{page}/{size}', [UserController::class, 'query']);
    // 获取某个用户资料详情
    Route::get('/user/{flag}/{uid}', [UserController::class, 'query']);
    // 启用/禁用用户
    Route::post('/user/status', [UserController::class, 'status']);
});
